<template>
  <div class="list-container">
    <!-- 左边 -->
    <div class="left-box-card" ref="left">
     <ArticleItem :data="articleList"/>
     <div class="pagination">
       <el-pagination
          background
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="query.pageNum"
          :page-sizes="[10, 20, 30, 50]"
          :page-size="query.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total">
        </el-pagination>
     </div>
    </div>
    <!-- 右边 -->
    <Right />
    <!-- 回到顶部 -->
    <el-backtop target="#app"></el-backtop>
  </div>
</template>

<script>
import { getArticleList } from "@/api/news/pc-web/article";
import ArticleItem from '@/news/views/list/ArticleItem'
import Right from '@/news/views/components/Right'
export default {
  name: "List",
  components:{Right,ArticleItem},
  data() {
    return {
      articleList: [], //articleList: [], // 文章表格数据
      query: {
        pageNum: 1, // 分页页码
        pageSize:10, // 页面数据条数
      },
        total: 0,
    };
  },
  created() {
    this.getArticleList();
  },
  methods: {
    handleSizeChange(val) {
      this.query.pageSize = val
      this.getArticleList();
      },
      handleCurrentChange(val) {
       this.query.pageNum = val
       this.getArticleList();
      },
    // 文章表格数据
    async getArticleList() {
      const { list, pageNum, pageSize, total } = await getArticleList(
        this.query
      );
      this.articleList = list;
      this.query.pageNum = Number(pageNum);
      this.query.pageSize = Number(pageSize);
      this.total = total;
      this.$refs.left.scrollIntoView({behavior: "smooth"})
    },
  },
};
</script>
<style lang="scss" scoped>
.list-container {
  margin: 15px 0px;
  display: flex;
  justify-content: space-between;
  width: 1166px;
}
 // 左边盒子
  .left-box-card {
    display: flex;
    flex-direction: column;
    padding-top: 10px;
    width: 100%;
    // width: 815px;
     border-radius: 4px;
    background-color: #fff;
    box-shadow: 0 2px 8px 0px rgba(122 192 241 / 30%);
    .pagination{
      margin:50px auto 20px auto;
    }
}
</style>
